<template>
  <div id="app">
    <!-- {{}} vue的插值语法-->
    <h1>{{ msg }}</h1>
    <div>
      <input type="text" v-model="info" placeholder="请输入待办事项" />
      <button @click="handleClick">添加</button>
    </div>
    <ul>
      <todo-item v-for="(item, index) in list" :item="item" :key="index">
        <!-- 2.6以前slot用法 -->
        <!-- <span slot="item" class="text1">{{ item }}</span> -->
        <!-- 2.6后slot用法 -->
        <template v-slot:item="itemProps">
          <span :style="{fontSize:'20px',color:itemProps.checked?'red':'blue'}">{{ item }}</span>
        </template>
      </todo-item>
    </ul>
  </div>
</template>

<script>
import TodoItem from "./components/TodoItem.vue";

export default {
  name: "App",
  components: {
    TodoItem,
  },
  data() {
    return {
      msg: "Welcome",
      info: "",
      list: [],
    };
  },
  methods: {
    handleClick() {
      this.list.push(this.info);
      this.info = "";
    },
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.text1 {
  font-size: 20px;
}
</style>
